package com.example.studentmanager;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Adapter;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    ListView lv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        lv = findViewById(R.id.lv);
        String[] arr = {"添加学生", "学生列表", "查询学生", "删除学生"};
        List<String> list = Arrays.asList(arr);

        ArrayAdapter adapter = new ArrayAdapter<>(MainActivity.this, android.R.layout.simple_list_item_1, list);
        lv.setAdapter(adapter);


        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int positon, long l) {
                switch (positon) {
                    case 0:
                        startActivity(new Intent(MainActivity.this, AddStudent.class));
                        break;
                    case 1:
                        startActivity(new Intent(MainActivity.this, AllStudent.class));

                        break;
                    case 2:
                        startActivity(new Intent(MainActivity.this, ShowStudent.class));
                        break;
                    case 3:
                        Intent intent = new Intent(MainActivity.this, DeleteStudent.class);
                        intent.putExtra("yy", "学号： ");
                        startActivity(intent);
                        break;
                    default:
                        break;
                }
            }
        });
    }
}